package com.bharat.matriService.managedBeans;

import java.io.Serializable;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;

import org.springframework.beans.factory.annotation.Autowired;

import com.bharat.matriService.model.Profile;
import com.bharat.matriService.model.RegistrationFormBean;
import com.bharat.matriService.services.CommonServices;

@ManagedBean(name = "reg", eager=true)
@SessionScoped
public class ProfileRegistration implements Serializable{

	private static final long serialVersionUID = 6808068414187042456L;

	@ManagedProperty(value = "#{profile}")
	private Profile profile;
	
	@ManagedProperty(value = "#{registrationFormBean}")
	private RegistrationFormBean registrationFormBean;

	@ManagedProperty(value = "#{commonServices}")
	private CommonServices commonServices;
	
	public void setCommonServices(CommonServices commonServices) {
		this.commonServices = commonServices;
	}
	
	public CommonServices getCommonServices() {
		return commonServices;
	}
	
	public RegistrationFormBean getRegistrationFormBean() {
		registrationFormBean.setProfileFor(commonServices.getEnumeration("PROFILE_FOR"));
		System.out.println("|||||||| "+ registrationFormBean);
		return registrationFormBean;
	}
	
	public void setRegistrationFormBean(
			RegistrationFormBean registrationFormBean) {
		this.registrationFormBean = registrationFormBean;
	}
	
	/* bean to initialize form */

	public ProfileRegistration() {
	}

	public void setProfile(Profile profile) {
		this.profile = profile;
	}

	public Profile getProfile() {
		return profile;
	}

	
	public String saveProfile() {
		// call service method to save profile.
		System.out.println(profile);
		//return "failed";
		commonServices.getEnumeration("PROFILE_FOR");
		return "success";
	}
}
